<template>
  <el-form ref="formRef" :model="form" label-width="80px" inline class="search-form">
    <el-form-item prop="">
      <el-input v-model="form.name" clearable placeholder="监控点名称" />
    </el-form-item>

    <el-form-item class="query-action">
      <el-button @click="resetBtn"> 重置 </el-button>
      <el-button type="primary" @click="$emit('getTableData',form.name)"> 查询 </el-button>
      <el-button v-permission="['GROUPCAMERASYNCHRONIZATION_ADD_BUTTON']" :disabled="ids.length === 0" type="primary" @click="$emit('addBtn')"> 批量新增状态监控 </el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import { default as request, cloud } from '@/framework/utils/request'
export default {
  name: 'GroupCameraPage',
  props: {
    formData: {
      type: Object,
      default: () => {}
    },
    ids: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      form: {},
      groupList: []
    }
  },
  async created() {
    // const data = await getPageRegionsList({ pageNo: 1, pageSize: 1000 })
    // this.groupList = data.data.list
  },
  methods: {
    resetBtn() {
      this.form = {}
      this.$emit('resetBtn', false)
    },
    deleteBtn() {
      this.$confirm('此操作将删除数据源, 是否删除?', '提示', {
        confirmButtonText: '删除',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        const data = await request({
          url: cloud.interfacePlatform + this.formData.deleteAddress,
          method: this.formData.method,
          data: { ids: this.ids }
        })
        if (data.code === '00000') {
          this.$message.success('删除成功')
          this.$emit('getTableData', this.form)
        }
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    }
  }
}
</script>

<style scoped lang="scss">

</style>
